package com.yiren.dbaa.module.practice_set.line.presenter;

import android.app.Activity;

import com.yiren.backstage.config.api.LoadConfigApi;
import com.yiren.backstage.config.bean.device.UserParamConfigBean;
import com.yiren.backstage.currency.entity.LineInfoEntity;
import com.yiren.dbaa.currency.api.CommonCallBack;
import com.yiren.dbaa.module.practice_set.line.contract.LineHomeContract;
import com.yiren.dbaa.module.practice_set.line.contract.OpenLineContract;
import com.yiren.dbaa.module.practice_set.line.model.LineHomeModel;
import com.yiren.dbaa.module.practice_set.line.model.OpenLineModel;

/**
 * @author lwb
 * @date : 2022/11/16 9:29
 * @description: 已公开线路
 */
public class OpenLinePresenter implements OpenLineContract.Presenter {

    private Activity activity;
    private OpenLineContract.Model openLineModel;
    private LineHomeContract.Model lineHomeModel;

    public OpenLinePresenter(Activity activity) {
        this.activity = activity;
        openLineModel = new OpenLineModel(activity);
        lineHomeModel = new LineHomeModel(activity);
    }

    @Override
    public void loadOpenLine(String siteCode, CommonCallBack callBack) {
        //从服务器获取线路
        UserParamConfigBean userParamConfigBean = LoadConfigApi.loadUserParamConfig(activity);
        lineHomeModel.getLineFromServer(userParamConfigBean.getUserInfo().getId().toString(), siteCode, true, callBack);
    }

    @Override
    public void setLineState(int state, LineInfoEntity lineInfo, CommonCallBack callBack) {
        openLineModel.changeLineState(state, lineInfo, callBack);
    }
}
